<?php
	include 'php/config.php';
	session_start();
	if (!isset($_SESSION["id_utente"])) {
		header("Location: " . $ISSUER_HOST . "/login.php");
		exit();
	} else if (!$_SESSION["admin"]) {
		header("Location: " . $ISSUER_HOST . "/forbidden.php");
		exit();
	}
?>
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF8">
<title>Open Badges - Nuovo Utente</title>
<link href="style.css" rel="stylesheet" type="text/css" />
<link rel="stylesheet" href="http://code.jquery.com/ui/1.10.2/themes/cupertino/jquery-ui.css" />
<script src="http://code.jquery.com/jquery-1.9.1.js"></script>
<script src="http://code.jquery.com/ui/1.10.2/jquery-ui.js"></script>
<script src="js/utils.js"></script>
<script src="js/new_user.js"></script>
<script>
$(function() {
	$('input[type="button"]').button();
});
</script>
</head>
<body>
<div id="topPan"><img src="images/logo.gif" alt="Education Zone" width="245" height="37" border="0"  class="logo" title="Education Zone"/>
  <p>Open Badges</p>
  <div id="topContactPan"> </div>
  <div id="topMenuPan">
    <div id="topMenuLeftPan"></div>
    <div id="topMenuMiddlePan">
      <ul>
        <li><a href="index.php">Home</a></li>
        <li><a href="badges_page.php">Badges</a></li>
        <li><a href="displayer_page.php">Displayer</a></li>
        <li><a href="universities.php">Università</a></li>
        <li><a href="refs.php">Riferimenti</a></li>
        <li><a href="contacts.php">Contatti</a></li>
        <?php
		if (!$_SESSION['id_utente']) {
    	?>
        <li class="contact"><a id="menuLogin" class="contact" href="login.php">Login</a></li>
	<?php
		} else {
	?>
	<li class="contact"><a class="contact" href="logout.php">Logout</a></li>
	<?php
		}
	?>
      </ul>
    </div>
    <div id="topMenuRightPan"></div>
  </div>
</div>
<div id="bodyPan">
  <div id="bodyLeftPan">
    <h2><span>Open Badges - Nuovo utente</span></h2>
	<p id="message" class="errorMsg"></p>
<form method="post">
<table border="0">
	<tr>
		<td><label>Cognome</label></td>
		<td><input id="lastName" name="lastname" type="text" maxLength="70" /></td>
		<td id="lastNameMsg" class="errorMsg"></td>
	</tr>
	<tr>
		<td><label>Nome</label></td>
		<td><input id="name" name="name" type="text" maxLength="70" /></td>
		<td id="nameMsg"  class="errorMsg"></td>
	</tr>
	<tr>
		<td><label>E-mail</label></td>
		<td><input id="email" name="email" type="text" maxLength="70" /></td>
		<td id="emailMsg"  class="errorMsg"></td>
	</tr>
	<tr>
		<td><label>Admin</label></td>
		<td><input id="admin" name="admin" type="checkbox" value="admin" onchange="alertAdmin(this)" /></td>
	</tr>
</table>
<p id="message" class="errorMsg"></p>
<input id="create" type="button" value="Crea" onclick="validateNewUserForm()"/>
</form>
</div>
<div id="bodyRightPan">
    <?php
	if (!$_SESSION['id_utente']) {
    ?>
    <h2 id="login"><span>Log</span>in</h2>
    <form id="loginForm">
    <p class="boldtext">Username</p>
    <p><input id="username" name="username" type="text"/></p>
    <p id="userMsg" class="errorMsg"></p>
    <p class="boldtext">Password</p>
    <p><input id="password" name="password" type="password"/></p>
    <p id="pswMsg" class="errorMsg"></p>
    <p><input type="button" value="Login" onclick="validateLoginForm()"/></p>
    </form>
    <?php
	}
    ?>
    <h2><span>Quick</span> links</h2>
    <ul>
      <li><a href="index.php">Home</a> </li>
      <?php
	if ($_SESSION['id_utente']) {
		if ($_SESSION['admin']) {
      ?>
      <li><a href="issue_page.php">Assegna badge</a> </li>
      <li><a href="new_badge_page.php">Nuova badge</a> </li>
      <li><a href="categories_page.php">Gestisci categorie</a> </li>
      <li><a href="new_user_page.php">Nuovo utente</a> </li>
      <?php
		} else {
      ?>
      <li><a href="personal_page.php">Pagina personale</a> </li>
      <?php
		}
      ?> 
      <li><a href="badges_page.php">Badges</a> </li>
      <li><a href="displayer_page.php">Displayer</a> </li>     
      <li><a href="change_password_page.php">Cambia password</a> </li>
      <li><a href="logout.php">Logout</a> </li>
      <?php
		} else {
      ?>
      <li><a href="badges_page.php">Badges</a> </li>
      <li><a href="displayer_page.php">Displayer</a> </li>
      <?php
		}
      ?> 
    </ul>
  </div>
</div>
<div id="footermainPan">
	  <div id="footerPan">
	    <ul>
	      <li><a href="index.php">Home</a>| </li>
	      <li><a href="badges_page.php">Badges</a>| </li>
	      <li><a href="displayer_page.php">Displayer</a>| </li>
      	      <?php if ($_SESSION['id_utente'] && !$_SESSION['admin']) { ?><li><a href="personal_page.php">Pagina personale</a>| </li> <?php } ?>
	      <li><a href="universities.php">Università</a>| </li>
	      <li><a href="refs.php">Riferimenti</a>| </li>
	      <li><a href="contacts.php">Contatti</a></li>
	    </ul>
	    <p class="copyright">©education zone. All right reserved.</p>
	    <ul class="templateworld">
	      <li>design by:</li>
	      <li><a href="http://www.templateworld.com" target="_blank">Template World</a></li>
	    </ul>
	    <div id="footerPanhtml"><a href="http://validator.w3.org/check?uri=referer" target="_blank">HTML</a></div>
	    <div id="footerPancss"><a href="http://jigsaw.w3.org/css-validator/check/referer" target="_blank">css</a></div>
	  </div>
	</div>
</body>
</html>
